<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/assets/css/layui.css">
    <link rel="stylesheet" href="/static/assets/css/view.css"/>
    <title>Title</title>
</head>
<body>
<body class="layui-view-body">
<form class="layui-form layui-form-pane" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">用户ID</label>
        <div class="layui-input-inline">
            <input id="ownerId" type="text"  name="ownerId" required  lay-verify="required" autocomplete="off" class="layui-input" disabled>
        </div>
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline">
            <input id="ownerName" type="text" name="ownerName" required  lay-verify="required" autocomplete="off" class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">注册时间</label>
        <div class="layui-input-inline">
            <input id="registTime" type="registTime" name="title" required  lay-verify="required" autocomplete="off" class="layui-input" disabled>

        </div>
        <label class="layui-form-label">电话号码</label>
        <div class="layui-input-inline">
            <input id="ownerTel" type="text" name="ownerTel" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="margin-left: 200px;margin-top: 20px">
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit lay-filter="formDemo">修改</button>
        </div>
    </div>
</form>
<script src="/static/assets/layui.all.js"></script>
<script src="/static/assets/jquery.min.js"></script>
<script>
    $(function () {
        //通过名称得到url传参的值
        function getQueryString(name) {
                var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
                var r = window.location.search.substr(1).match(reg);
                if (r != null) {
                    return unescape(r[2]);
                }
                return null;
            }
        // 这样调用：
        var ownerId = getQueryString("ownerId");
        $.ajax({
                url:"/owner/selectById"
                ,type:"post"
                ,headers:{'Content-Type':'application/json;charset=utf8'}
                ,data:JSON.stringify({ownerId:ownerId})
                ,dataType:"json"
                ,success:function (data) {
                    console.log("id查询用户成功")
                    console.log(data)
                    var owner = data.data.owner
                    $("#ownerId").val(owner.ownerId)
                    $("#ownerName").val(owner.ownerName)
                    $("#ownerTel").val(owner.ownerTel)
                    $("#registTime").val(owner.registTime)
                }
                ,error:function () {
                    console.log("请求失败")
                }
            })

        //Demo
        layui.use(['form','layer'], function(){
            var form = layui.form,
            layer = layui.layer;
            //监听提交

            form.on('submit(formDemo)', function(data){
                $.ajax({
                    url: '/owner/updateOwner',
                    type: 'post',
                    data: data.field,
                    dataType: 'json',
                    success: function (res) {
                        layer.msg('正在修改')
                        console.log(res)
                    },
                    error: function (res) {

                    }
                })
                return false;
            });
        });

    })

</script>
<script>

</script>
</body>
</body>
</html>